﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Infrastructure;
using Infrastructure.DataTypes;

namespace RecommenderSystem
{
    /// <summary>
    /// this control used to show the item`s data on the "welcome" page.
    /// </summary>
    public partial class UCLWelcomeItem : UserControl
    {
        string itemID;



        public UCLWelcomeItem()
        {
            InitializeComponent();
            itemID = null;

        }
        public UCLWelcomeItem(Item<Discrete> item)
        {
            InitializeComponent();
            itemID = item.ItemID;
            string gn = "Genres : ";
            foreach (KeyValuePair<string, string> data in item.Data_Attributes)
            {
                switch (data.Key)
                {
                    case "title":
                        labelTitle.Text = data.Value;


                        break;
                    case "video_release_date":
                        labelReleaseDate.Text = "Video release date :\n   " + data.Value;
                        break;
                    case "IMDb_URL":
                        // labelIMDB.Text = data.Value;
                        break;
                    default:
                        if (gn == "Genre : ")
                        {
                            gn = gn + data.Value.ToString();
                        }
                        else
                        {   //showing only one single genre
                           // gn = gn + "\n    " + data.Value.ToString();
                        }
                        break;
                }
            }
            labelGenres.Text = gn;

            double avg = item.StatisticsAttributes.AverageRating;
            avg = Math.Round(avg, 2);
            double timesRated = item.StatisticsAttributes.VoteCount;
            labelTimesRated.Text = labelTimesRated.Text + " " + timesRated;
            labelAvgRating.Text = labelAvgRating.Text + " " + avg;


        }

        private void groupBox1_Enter(object sender, EventArgs e)
        {

        }


    }
}
